

/***
 * @Date            : 2024-12-09 23:35:31
 * @Author          : AnimateX(Baron)
 * @LastEditors     : AnimateX(Baron)
 * @LastEditTime    : 2024-12-09 23:35:43
 * @FilePath        : /include/p16.h
 * @CopyRight       : Copyright (c) 2024 RockChip Technology Co. Ltd. All rights reserved.
 * @Description     :
 learn container
 */

#pragma once
#include <cstddef>


namespace CourseP16 {
    using Index = std::ptrdiff_t;

    void test_p16_2();
    void homework_01();
    void homework_02();
    void homework_03();
    void homework_04();

    void course_16_3();
    void course_16_4();
    void homework_16_4();
    void course_16_5();
    void course_16_5_add();
    void homework_16_6();

    template<typename T>
    class SignedArrayView {
    private:
        T& m_array;

    public:
        SignedArrayView(T& array)
            : m_array {array} {}

        // overload
        constexpr auto& operator[](Index index) {
            return m_array[static_cast<typename T::size_type>(index)];
        }

        constexpr const auto& operator[](Index index) const {
            return m_array[static_cast<typename T::size_type>(index)];
        }

        constexpr auto ssize() const {
            return static_cast<Index>(m_array.size());
        }
    };

    void course_16_7();
    void homework_16_8_1();
    void homework_16_8_2();
}
